package defpackage; import android.content.Intent; import android.content.pm.PackageManager; import android.os.AsyncTask; import android.os.Bundle; import android.text.TextUtils; import android.webkit.JavascriptInterface; import cn.wps.moffice.OfficeApp; import cn.wps.moffice.main.common.ServerParamsUtil; import cn.wps.moffice.main.framework.BaseTitleActivity; import cn.wps.moffice.main.framework.IBaseActivity; import cn.wps.moffice.main.membership.server.MemberTaskJSInterface; import cn.wps.moffice.main.membership.task.TaskUtil; import cn.wps.moffice.main.membershipshell.MemberShipWebViewShellActivity; import cn.wps.moffice_eng.R; import com.appsflyer.AppsFlyerProperties; import defpackage.gwa; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import org.json.JSONException; import org.json.JSONObject; /* renamed from: gvr reason: default package */ public final class gvr extends IBaseActivity implements gwa.b { private gvs hFh; private gwa hFi; private boolean hFj; private boolean hFk; private boolean hFl; private boolean hFm; private boolean hFn; private boolean hFo; private boolean hFp; private boolean hFq; private boolean hFr; private boolean hFs; private boolean hFt; private a hFu; private String hFv; private boolean hFw; /* access modifiers changed from: package-private */ /* renamed from: gvr$a */ public class a extends AsyncTask<Void, Void, ArrayList<String>> { private a() { } /* synthetic */ a(gvr gvr, byte b) { this(); } private static ArrayList<String> bMt() { try { return gvk.xD(fok.bBq().geJ.bBh().userId); } catch (Exception e) { e.printStackTrace(); return null; } } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object[]] */ /* access modifiers changed from: protected */ @Override // android.os.AsyncTask public final /* synthetic */ ArrayList<String> doInBackground(Void[] voidArr) { return bMt(); } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ /* access modifiers changed from: protected */ @Override // android.os.AsyncTask public final /* synthetic */ void onPostExecute(ArrayList<String> arrayList) { ArrayList<String> arrayList2 = arrayList; if (arrayList2 != null) { Iterator<String> it = arrayList2.iterator(); while (it.hasNext()) { String next = it.next(); if ("android_regist".equals(next)) { gvr.this.hFm = true; } else if ("sign".equals(next)) { gvr.this.hFo = true; } else if (next.startsWith("share_articles")) { gvr.this.hFq = true; } else if ("software_popular".equals(next)) { gvr.this.hFr = true; } else if ("personal_info".equals(next)) { gvr.this.hFt = true; } } if (!gvr.this.hFm && gvr.this.hFi != null) { String str = fok.bBq().geJ.bBh().userId; gwa gwa = gvr.this.hFi; try { if (lwd.hu(gwa.mContext) && !TextUtils.isEmpty(str) && (gwa.hFN == null || gwa.hFN.getStatus() != AsyncTask.Status.RUNNING)) { gwa.hFN = new gwa.d(); gwa.hFN.execute(new String[]{str}); } } catch (Exception e) { } } if (!gvr.this.hFn && gvr.this.hFo) { gvr.this.xG("sign"); } if (!gvr.this.hFp && gvr.this.hFq) { gvr.this.xG("share_articles"); } if (!gvr.this.hFs && gvr.this.hFt) { gvr.this.xG("personal_info"); } } } } /* renamed from: gvr$b */ class b extends MemberTaskJSInterface { private b() { } /* synthetic */ b(gvr gvr, byte b) { this(); } @Override // cn.wps.moffice.main.membership.server.MemberTaskJSInterface @JavascriptInterface public final String getClientParams() { if (gvr.this.hFv == null) { JSONObject jSONObject = new JSONObject(); int i = -1; try { i = gvr.this.mActivity.getPackageManager().getPackageInfo(gvr.this.mActivity.getPackageName(), 16384).versionCode; } catch (PackageManager.NameNotFoundException e) { } try { jSONObject.put("version_code", i); jSONObject.put(AppsFlyerProperties.CHANNEL, OfficeApp.arx().arB()); boolean tH = ServerParamsUtil.tH("active_task_web"); jSONObject.put("active_task_top", tH); jSONObject.put("active_task_mid", tH); jSONObject.put("task_regist", true); jSONObject.put("task_sign", true); jSONObject.put("task_soft_rating", true); jSONObject.put("task_complete_info", true); jSONObject.put("task_time_usage", true); jSONObject.put("task_bottom_link", ServerParamsUtil.tH("task_bottom_link")); } catch (JSONException e2) { } gvr.this.hFv = jSONObject.toString(); } return gvr.this.hFv; } @Override // cn.wps.moffice.main.membership.server.MemberTaskJSInterface @JavascriptInterface public final void goToLogin() { gvr.g(gvr.this); } @Override // cn.wps.moffice.main.membership.server.MemberTaskJSInterface @JavascriptInterface public final String httpGet(String str, String str2, int i) { int i2 = 0; JSONObject b = gvr.this.b(str, str2, i, false, null); while (b.getInt("errorCode") != 0 && i2 < 2) { try { i2++; b = gvr.this.b(str, str2, i, false, null); } catch (JSONException e) { } } if (b.getInt("errorCode") != 0) { gvr.b(gvr.this); } return b.toString(); } @Override // cn.wps.moffice.main.membership.server.MemberTaskJSInterface @JavascriptInterface public final String httpPost(String str, String str2, String str3, int i) { JSONObject b = gvr.this.b(str, str3, i, true, str2); while (b.getInt("errorCode") != 0) { try { b = gvr.this.b(str, str3, i, true, str2); } catch (JSONException e) { } } if (b.getInt("errorCode") != 0) { gvr.b(gvr.this); } return b.toString(); } @Override // cn.wps.moffice.main.membership.server.MemberTaskJSInterface @JavascriptInterface public final void openTask(String str, String str2, String str3, String str4) { gvr.a(gvr.this, str, str2); dwp.at("public_assginments_click", str4); } @Override // cn.wps.moffice.main.membership.server.MemberTaskJSInterface @JavascriptInterface public final void request(String str, String str2) { if (MemberTaskJSInterface.FUNC_SHOW_PROGRESSBAR.equals(str)) { gvr.this.hFh.byk(); } else if (MemberTaskJSInterface.FUNC_HIDE_PROGRESSBAR.equals(str)) { gvr.this.hFh.byl(); } else if (MemberTaskJSInterface.FUNC_REGISTRATION.equals(str)) { BaseTitleActivity baseTitleActivity = gvr.this.mActivity; Intent intent = new Intent(baseTitleActivity, MemberShipWebViewShellActivity.class); intent.putExtra("membership_webview_activity_type_key", "membership_webview_activity_type_sign"); baseTitleActivity.startActivityForResult(intent, 100); } else if (MemberTaskJSInterface.FUNC_SOFTWARE_RATING.equals(str)) { gvr.d(gvr.this); } else if (MemberTaskJSInterface.FUNC_SHOW_TIME_USAGE_TIPS.equals(str)) { gvr.e(gvr.this); } else if (MemberTaskJSInterface.FUNC_COMPLETE_USER_INFO.equals(str)) { gvr.f(gvr.this); } } @Override // cn.wps.moffice.main.membership.server.MemberTaskJSInterface @JavascriptInterface public final void requestSession() { gvr.h(gvr.this); } } public gvr(BaseTitleActivity baseTitleActivity) { super(baseTitleActivity); } static /* synthetic */ void a(gvr gvr, String str, String str2) { BaseTitleActivity baseTitleActivity = gvr.mActivity; Intent intent = new Intent(baseTitleActivity, MemberShipWebViewShellActivity.class); intent.putExtra("membership_webview_activity_type_key", "membership_webview_activity_type_do_task"); intent.putExtra("membership_webview_activity_header_key", str2); intent.putExtra("membership_webview_activity_link_key", str); baseTitleActivity.startActivity(intent); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ /* JADX WARNING: Removed duplicated region for block: B:12:0x0025 */ /* JADX WARNING: Removed duplicated region for block: B:8:0x0019 */ private JSONObject b(String str, String str2, int i, boolean z, String str3) { HashMap<String, String> hashMap; HashMap<String, String> hashMap2; String z2; int i2 = 2; JSONObject jSONObject = new JSONObject(); int i3 = 0; try { hashMap2 = wR(str2); try { if (!lwd.hu(this.mActivity)) { i3 = 2; } } catch (JSONException e) { hashMap = hashMap2; i3 = 5; hashMap2 = hashMap; if (i3 != 0) { } } } catch (JSONException e2) { hashMap = null; i3 = 5; hashMap2 = hashMap; if (i3 != 0) { } } if (i3 != 0) { return b(jSONObject, i3, ""); } if (z) { try { z2 = lwd.z(lwd.a(str, str3, hashMap2, i)); i2 = i3; } catch (IOException e3) { if (!lwd.hu(this.mActivity)) { z2 = ""; } else { i2 = 4; z2 = ""; } } } else { z2 = lwd.z(lwd.a(str, hashMap2, i)); i2 = i3; } return b(jSONObject, i2, z2); } private static JSONObject b(JSONObject jSONObject, int i, String str) { try { jSONObject.put("errorCode", i); jSONObject.put("body", str); } catch (JSONException e) { } return jSONObject; } static /* synthetic */ void b(gvr gvr) { if (!gvr.hFw) { gvr.mActivity.runOnUiThread(new Runnable() { /* class defpackage.gvr.AnonymousClass6 */ public final void run() { gvr.this.hFh.onError(); } }); } } private void bVI() { if (this.hFu == null || this.hFu.getStatus() != AsyncTask.Status.RUNNING) { this.hFn = this.hFo; this.hFp = this.hFq; this.hFs = this.hFt; this.hFu = new a(this, (byte) 0); this.hFu.execute(new Void[0]); } } static /* synthetic */ void d(gvr gvr) { cvo.c(gvr.mActivity, new Runnable() { /* class defpackage.gvr.AnonymousClass5 */ public final void run() { try { String str = fok.bBq().geJ.bBh().userId; TaskUtil.CountSoftwareReview.xR(str); if (!gvr.this.hFr) { gwa gwa = gvr.this.hFi; try { if (lwd.hu(gwa.mContext) && !TextUtils.isEmpty(str) && TaskUtil.CountSoftwareReview.xS(str) && (gwa.hFQ == null || gwa.hFQ.getStatus() != AsyncTask.Status.RUNNING)) { gwa.hFQ = new gwa.f(gwa, (byte) 0); gwa.hFQ.execute(new String[]{str}); } } catch (Exception e) { } gvr.this.xG("software_popular"); } } catch (Exception e2) { e2.printStackTrace(); } } }); } static /* synthetic */ void e(gvr gvr) { TaskUtil.a(gvr.mActivity, R.string.home_task_display_time_rules, R.string.home_task_know, null); } static /* synthetic */ void f(gvr gvr) { gvr.hFl = true; fvf.c(gvr.mActivity, false); } static /* synthetic */ void g(gvr gvr) { gvr.mActivity.runOnUiThread(new Runnable() { /* class defpackage.gvr.AnonymousClass2 */ public final void run() { gvr.this.hFj = true; ebo.F(gvr.this.mActivity); } }); } static /* synthetic */ void h(gvr gvr) { gvr.mActivity.runOnUiThread(new Runnable() { /* class defpackage.gvr.AnonymousClass3 */ public final void run() { String asP = gvk.asP(); if (asP == null) { asP = ""; } gvr.this.hFh.mWebView.loadUrl("javascript:appJs_sessionCallback('" + asP + "')"); } }); } private static HashMap<String, String> wR(String str) throws JSONException { if (str == null || str.length() == 0) { return null; } JSONObject jSONObject = new JSONObject(str); HashMap<String, String> hashMap = new HashMap<>(); Iterator<String> keys = jSONObject.keys(); while (keys.hasNext()) { String next = keys.next(); hashMap.put(next, jSONObject.getString(next)); } return hashMap; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void xG(final String str) { this.mActivity.runOnUiThread(new Runnable() { /* class defpackage.gvr.AnonymousClass4 */ public final void run() { gvr.this.hFh.mWebView.loadUrl("javascript:doneTask('" + str + "')"); } }); } @Override // defpackage.fyr public final fys createRootView() { if (this.hFh == null) { this.hFh = new gvs(this.mActivity, new b(this, (byte) 0)); } return this.hFh; } @Override // defpackage.fyr public final void onActivityResult(int i, int i2, Intent intent) { super.onActivityResult(i, i2, intent); if (i == 100) { if (!this.hFo) { bVI(); } } else if (i == 200 && !this.hFt) { bVI(); } } @Override // defpackage.fyr public final void onBackPressed() { boolean z; if (this.hFh != null) { gvs gvs = this.hFh; if ("https://vip.wps.cn/static/lezhuan/".equalsIgnoreCase(gvs.mWebView.getUrl()) || !gvs.mWebView.canGoBack()) { z = false; } else { gvs.mWebView.goBack(); z = true; } if (z) { return; } } super.onBackPressed(); } @Override // defpackage.fyr public final void onCreate(Bundle bundle) { super.onCreate(bundle); this.hFw = false; if (luf.gQ(this.mActivity)) { this.mActivity.setRequestedOrientation(1); } getTitleBar().setIsNeedMultiDoc(false); getTitleBar().setCustomBackOpt(new Runnable() { /* class defpackage.gvr.AnonymousClass1 */ public final void run() { gvr.this.onBackPressed(); } }); this.hFi = new gwa(this.mActivity, this); if (ebo.arU()) { bVI(); String str = fok.bBq().geJ.bBh().userId; gwa gwa = this.hFi; gwa.xN(str); gwa.xM(str); } dwp.km("public_my_task"); } @Override // defpackage.fyr public final void onDestroy() { super.onDestroy(); gvs gvs = this.hFh; ebj.d(gvs.mWebView); gvs.mHandler.removeCallbacks(gvs.hFC); gvs.hFA = false; this.hFw = true; } @Override // defpackage.fyr public final void onResume() { super.onResume(); if (this.hFj) { if (ebo.arU()) { bVI(); this.hFh.byk(); this.hFh.mWebView.reload(); } this.hFj = false; } else if (this.hFk) { if (!this.hFq) { bVI(); } } else if (this.hFl && !this.hFt) { bVI(); } } @Override // defpackage.gwa.b public final void xH(String str) { if (str != null) { xG(str); } } }